import Koa from 'koa'
import router from './src/routes'
import bodyParser from 'koa-bodyparser'
import Logger from 'node-logger'

const app = new Koa()
const port = 3000;
const logfile = './.log';

app.keys = ['webhooks']
app.context.log = Logger.createLogger(logfile);
app.context.log.format = (level, date, message) => `[${level}]: [${date}]\r\n${message.trim()}`;

// bodyParser
app.use(bodyParser())

// user and admin routes
app.use(router.routes())

app.listen(port, () => {
  console.log(`${app.keys[0]} is start on https://localhost:${port}`);
})
